#!/bin/sh
# Run a Linux Counter script
# Reason: the use of special libdirs and so on in the scripts
# require a bit of setting up.
# The ideal is that only this script needs to change when the counter
# moves.
# This version is in SH. If "source"d with no argument, it
# sets the right variables.
if [ -f ./.counter.ini ]; then
   . ./.counter.ini
else
   exdir=`dirname $0`
   homedir=`dirname $exdir`
   if [ -f $homedir/.counter.ini ]; then
     . $homedir/.counter.ini
   else
      homedir=/home/counter
      website=counter.li.org
   fi
fi
COUNTER_ROOT=$homedir
COUNTER_HOST=$website
COUNTER_DBHOST=${dbhost-localhost}
COUNTER_DBNAME=${dbname-counter}

export COUNTER_ROOT
export COUNTER_HOST
export COUNTER_DBHOST
export COUNTER_DBNAME
libdir=$homedir/lib

cd $homedir
PATH=$PATH:/usr/local/bin:/bin:/usr/bin:$homedir:$homedir/tools
PERL5LIB=$libdir;
export PATH
export PERL5LIB
if [ x$1 != x -a x$1 != x--noexec ]; then
   date >> logs/runscript.log
   id >> logs/runscript.log
   echo "Executing $*" >> logs/runscript.log
   exec $*
   # If we get here:
   echo "Exec $* failed" >> logs/runscript.log
fi



